import CreepController from "../controller"


class RoleClaimer {

    /**
     *
     * @param creep
     * @returns
     */
    static loop(creep: Creep) {
        // Game.spawns['Spawn2'].spawnCreep([MOVE, CLAIM], 'C01', {memory: {role: 'claimer'}});
        // Game.spawns['Spawn1'].spawnCreep([WORK, WORK, CARRY, CARRY, MOVE, MOVE, MOVE, MOVE], 'RR01', {memory: {role: 'claimer'}});
        const roomName = 'E35S48'
        const room = Game.rooms[roomName]
        if (creep.room.name != roomName) {
            creep.goTo(new RoomPosition(25, 25, roomName))
        }
        else {
            if (creep.claimController(room.controller) == ERR_NOT_IN_RANGE) {
                creep.goTo(room.controller.pos)
            }
            // const roomName: string = 'E39S52'
            // if (!creep.memory.data['harvestRoom']) {
            //     creep.memory.data['harvestRoom'] = roomName
            // }
            // const remoteSource = CreepController.remoteHarvesterFindRemoteSource(creep)
            // if (remoteSource) {
            //     const status = creep.harvest(remoteSource)
            //     if (status == OK) {
            //         creep.memory.stand = true
            //     }
            //     else if (status == ERR_NOT_IN_RANGE) {
            //         creep.goTo(remoteSource.pos)
            //     }
            // }
        }
    }
}

export default RoleClaimer
